﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace mfe.lib
{
    public class Logger
    {
        public static void Log(Exception ex)
        {
            try
            {
                //create a file if not exist
                string filename = string.Concat(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, ".txt");
                System.Diagnostics.Debug.WriteLine(filename);
                TextWriter tw = new StreamWriter(filename, true);
                tw.WriteLine(DateTime.Now.ToString());
                tw.WriteLine(ex.ToString());
                tw.WriteLine();
                tw.WriteLine();
                tw.Close();
                tw.Dispose();
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.WriteLine(e.ToString());
            }
        }
    }
}
